

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>菜谱管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <#include "../../include/layui.ftl" />
    <#include "../../include/pTable.ftl" />
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <form  id="queryForm">
                <input type="hidden" id="className" name="className" value="${className!}" />
                <input type="hidden" id="modleName" name="modleName" value="${modleName!}" />
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" autocomplete="off" class="layui-input">
                            <input type="hidden" name="name_searchType" value="like">
                        </div>
                    </div>
                </div>
            </form>
        </div>

        <div class="layui-card-body">

            <table id="lay-table" lay-filter="lay-table"></table>
            <script type="text/html" id="toolbar">
            </script>
        </div>
    </div>
</div>
<script>
    var layers = null;
    layui.config({
        base: '${path}/plug-in/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','tables','layers','view'],function () {
        var tables = layui.tables,
            table = layui.table,
            view = layui.view,
            layer = layui.layer,
            $ = layui.$;
        layers = layui.layers;
        var parmer = {
            url:'/console/com.fs.common.pojo.Recipes/list',
            defaultToolbar: ['filter'],
            cols:[[
                    {field:"name",width:180,title:"名称"}
                    ,{field:"foods",width:350,title:"食材"}
                    ,{field:"step",width:350,title:"步骤"}
                    ,{field:"effect",width:200,title:"功效"}
                    ,{field:"suitable",width:200,title:"适宜体质"}
                    ,{field:"modeType",width:100,title:"分娩方式"}
                    ,{field:"feedType",width:100,title:"喂养方式"}
                    ,{field:"video",width:100,title:"制作视频",templet:function (d) {
                        if(d.video == null || d.video == ''){
                            return "暂无视频";
                        }else{
                            return "<a href='javascript:void(0);' onclick='viewVideo(\""+d.video+"\")'>点击查看</a>";
                        }
                    }}
                ]]
        };
        var $tables = tables.renderTable(parmer);

        //头工具栏事件
        table.on('toolbar(lay-table)', function(obj){
            switch(obj.event){
                case '01':
                    layers.add({
                        area:['700px', '820px']
                    });
                    break;
                case '02':
                    layers.edit({
                        area:['700px', '820px'],
                        data: p.data
                    });
                    break;
                case '03':
                    layers.delete({url:'/console/com.fs.common.pojo.Recipes/delete',data:p.data});
                    break;
                case '04':
                    layers.view({
                        area:['700px', '760px'],
                        data: p.data
                    });
                    break;
                case '05':
                    var where = $("#queryForm").serializeObject();
                    $tables.reload({
                        where: where,
                        text: {none: '暂无数据！'}
                    });
                    break;
                case '26':
                    layer.prompt({title: '请输入当前帐号密码，并确认后继续', formType: 1}, function(pass, index){
                        layer.close(index);
                        if(pass == ''){
                            layer.msg('请输入密码');
                            return;
                        }
                        $.post("/console/user/rewrite/confirmPassword",{password:pass},function (res) {
                           if(res.data){
                               layer.confirm('生成食谱模版时间过长，确定需要重新生成吗？', function(index){
                                   $.post("/console/recipesTemplate/rewrite/createAll");
                                   layer.msg('已提交到后台处理');
                                   layer.close(index);
                               });
                           }else{
                               layer.msg('密码输入错误，请检查后重试');
                               return;
                           }
                        });

                    });

                    break;
            };
        });
    });
    function viewVideo(id) {
        p.data.id = id;
        layers.view({
            area:['700px', '530px'],
            data: p.data,
            content:'/console/video?id='+id
        });
    }
</script>
</body>
</html>